<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<script src="lib/jquery-3.4.1.min.js"></script>
	<script src="lib/jquery-3.4.1.js"></script>
	<link rel="stylesheet" href="css/denglu.css">
</head>
<body onload="randompic()">
	<form name="form1">
	<table align="center" class="denglu">
		<tr>
			<td>用户名：</td>
			<td>
				<input type="text" name="username"></input>
			</td>
		</tr>
		<tr>
			<td>密&nbsp;&nbsp;&nbsp;码：</td>
			<td>
				<input type="password" name="password"></input>
			</td>
		</tr>
		<tr>
			<td>
				<button type="submit" onclick="btnlog()">登录</button>
			</td>
			<td>
				<button type="reset">重置</button>
			</td>
		</tr>
		<div class="beizhu">用户名为:yesung&nbsp&nbsp密码为:1106</div>
	</table>
    </form>
</body>
</html>
<script type="text/javascript">
	function randompic(){
		setInterval(function(){
			var i = Math.floor(Math.random()*5)
		    var src = ''
		    switch(i){
		    	case 0:
			        src = "images/0.jpg";
			        break;
			    case 1:
			        src = "images/1.jpg";
			        break;
			    case 2:
			        src = "images/2.jpg";
			        break;
			    case 3:
			        src = "images/3.jpg";
			        break;
			    case 4:
			        src = "images/4.jpg";
			        break;
		    }
		    $('body').attr('background',src)
		},2000)
	}
	var zhanghudata= [["yesung","1106"],["kiki","1026"],["gyu","1106"]]

	function btnlog(){
		if(document.form1.username.value==""){
			alert("用户名不能为空!");
			return false
		}
		if(document.form1.password.value==""){
			alert("密码不能为空!");
			return false
		}

		var user = document.form1.username.value;
		var psword = document.form1.password.value;
		var panduan = false
		for(var i = 0;i<zhanghudata.length;i++){
			if (zhanghudata[i][0]=user && zhanghudata[i][1] == psword){
				panduan = true;
				break
			}
		}
		if (panduan){
			alert("登录成功!")
			window.open("./index.html")
		}else{
			alert("账号密码不存在!")
		}
	}
</script>